package com.example.log.alarm.advice.logger;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.IThrowableProxy;
import ch.qos.logback.classic.spi.LoggerContextVO;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.slf4j.Marker;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @program: spring-agent
 * @description:
 * @author: zt22328 赵儒定
 * @create: 2023-05-05 16:01
 **/
@Data
@ToString
public class LogInfo {

    /**
     * md5key(loggerName+level+message+stackTrace)
     */
    private String loggerId;

    private String loggerName;

    private String level;

    private String message;
    /**
     * md5key(stackTrace)
     */
    private String stackTraceId;

    private String stackTrace;

    private List<LogDesc> logDescList = new ArrayList<>();

    public void addLogDesc(String threadName, LocalDateTime triggerTime, Map<String, String> mdc) {
        this.logDescList.add(new LogDesc(threadName, triggerTime, mdc));
    }

    @Data
    @ToString
    @AllArgsConstructor
    @NoArgsConstructor
    public static class LogDesc {

        private String threadName;

        private LocalDateTime triggerTime;

        private Map<String, String> mdc;

    }

}
